#include <Bounce2.h>

const unsigned int BAUD_RATE = 9600;
const unsigned int X_PIN = 0;
const unsigned int Y_PIN = 1;
const unsigned int Z_PIN = 2;
const unsigned int BUTTON_PIN = 12;
const unsigned int NUM_AXES = 3;
const unsigned int PINS[NUM_AXES] = {X_PIN, Y_PIN, Z_PIN};
const unsigned int BUFFER_SIZE = 16;
int buffer[NUM_AXES][BUFFER_SIZE];
int buffer_pos[NUM_AXES] = {0};

void setup()
{
    Serial.begin(BAUD_RATE);
    pinMode(BUTTON_PIN, INPUT);
}
   int get_axis(const int axis)
{
  delay(1);  
  buffer[axis][buffer_pos[axis]] = analogRead(axis);
  buffer_pos[axis] = (buffer_pos[axis] + 1) % BUFFER_SIZE;
  
  long sum = 0;
    for(int i = 0; i < BUFFER_SIZE; i++)
      sum =+ buffer[axis][i];
    
    return (sum / BUFFER_SIZE);
}

void loop()
{
  for(int i = 0; i < NUM_AXES; i++)
  {
    Serial.print(get_axis(i));
    Serial.print(" ");
  }
  Serial.println();
}

